# Maintainer: Andreas Radke <andyrtr@archlinux.org>

# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
#  - enable omap, exynos, tegra, etnaviv for v7
#  - move cairo to makedepends from checkdepends

pkgname=libdrm
pkgver=2.4.123
pkgrel=1
pkgdesc="Userspace interface to kernel DRM services"
url="https://dri.freedesktop.org/"
arch=(x86_64)
license=('MIT')
depends=('libpciaccess' 'glibc')
makedepends=('python-docutils' 'meson' 'cairo')
optdepends=('cairo: needed for modetest tool')
replaces=('libdrm-new' 'libdrm-nouveau')
source=(https://dri.freedesktop.org/$pkgname/$pkgname-$pkgver.tar.xz{,.sig}
        COPYING)
sha512sums=('d3e6ba26bbd609fd87ca131690547eeb6a903c0a8c28b7f5cd5d0947619da09f31daf7bf4b6c38bf5e5dc173e2ccba476338ef682d8cf06d6b71ba73fc9b948d'
            'SKIP'
            'b0ca349b882a4326b19f81f22804fabdb6fb7aef31cdc7b16b0a7ae191bfbb50c7daddb2fc4e6c33f1136af06d060a273de36f6f3412ea326f16fa4309fda660')
# validpgpkeys=('10A6D91DA1B05BD29F6DEBAC0C74F35979C486BE') # David Airlie <airlied@redhat.com>
# validpgpkeys=('34FF9526CFEF0E97A340E2E40FDE7BE0E88F5E48') # emersion <contact@emersion.fr>
# validpgpkeys=('E9E246A89E65374EB8355796B8B5FA0EFC1EC2FE') # "Leo Liu <leo.liu@amd.com>"
# validpgpkeys=('899A810900B815807742E6D895A677A230AC4AA9') # Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
# validpgpkeys=('2617F6F8DEBB0A7A15C405C983FD600E340FB5FF') # Samuel Pitoiset <samuel.pitoiset@gmail.com>
# validpgpkeys=('F3A52DB8ECE9EB9E33BC48C6917A3EE97A0FCD1A') # "Marek Olšák <maraeo@gmail.com>"
# validpgpkeys=('34FF9526CFEF0E97A340E2E40FDE7BE0E88F5E48') # Simon Ser <contact@emersion.fr>
validpgpkeys=('3BB639E56F861FA2E86505690FDD682D974CA72A') # Matt Turner <mattst88@gmail.com>

build() {
  [[ "$CARCH" == "armv7h" ]] && CONFIG="-Domap=enabled -Dexynos=enabled -Dtegra=enabled -Detnaviv=enabled"
  arch-meson $pkgname-$pkgver build \
    -D udev=true \
    -D valgrind=disabled \
    -D install-test-programs=true \
    $CONFIG
  meson compile -C build
}

check() {
  meson test -C build --print-errorlogs
}

package() {
  meson install -C build --destdir "$pkgdir"
  install -Dt "$pkgdir/usr/share/licenses/$pkgname" -m644 COPYING
}
